﻿
//自动义双击方法
function CustomDbClick() {
}
//自定义新增方法
var fnCustomAdd = function () {
}
//自定义修改方法
var fnCustomEdit = function () {
    var recordID = myDataTable.getSelectedRows()[0];
    var record = myDataTable.getRecord(recordID);
    var vid = record.getData(const_entityID);
    var customerId = record.getData("CustomerId");
    if (vid != "") {
        var SaveUrl = "AjaxData/CustomOperating.aspx?r=" + Math.random() + "&action=check&entity=CrmCustomerReturn&id=" + vid;
        YAHOO.util.Connect.asyncRequest('POST', SaveUrl, {
            success: function (res) {
                try {
                    var str = res.responseText;
                    if (str == "1") {  //可以修改
                        ModifyCustomer(vid, customerId);
                    } else if (str == "2") {  //自己可以修改
                        alert("您不是接收人不能修改该客户信息!");
                        return;
                    } else {
                        alert("操作异常!");
                        return;
                    }
                }
                catch (e) {
                }
                finally {
                }
            },
            failure: function (error) {
                alert("数据错误：" + error.statusText);
            }
        }, null);
    }
}
var ModifyCustomer = function (vid, customerId) {
    window.parent.$("#tabs").tabs('close', '修改客户信息');
    var pagetitle = "修改客户信息";
    parent.addTabs(pagetitle, '../Crm/Customer/AddCustomer.aspx?r=' + Math.random() + '&back=2&type=0&flag=2&entity=CrmCustomer&id=' + customerId + '&rId=' + vid + '&title=' + encodeURI(pagetitle));
    parent.NeedRefreshPage = this;
}
//自定义删除方法
var fnCustomDeleteData = function () {
    YAHOO.example.container.dialog3.hide();
}
//格式化状态列
var formatState = function (elCell, oRecord, oColumn, sData) {
    if (sData == "0") {
        elCell.innerHTML = "未修改";
    } else if (sData == "1") {
        elCell.innerHTML = "已修改";
    }
}
//格式化修改时间
var formatModifyTime = function (elCell, oRecord, oColumn, sData) {
    if (sData == "1900-01-01") {
        elCell.innerHTML = "";
    }
}